<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\PromoterLevel;
use App\Traits\Controllers\AdminTraits;
use App\Transformers\PromoterLevelTransFormer;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Http\Request;

class PromoterLevelController extends Controller
{
    /**
     * 分销等级表增删改查
     */
    use AdminTraits;

    public $model = PromoterLevel::class;

    public $transformer = PromoterLevelTransFormer::class;


    /**
     * 参数验证规则
     *
     * @param Request $request
     * @return array
     */
    public function rules(Request $request): array
    {
        switch ($request->method()) {
            case 'GET':
                return [];
                break;
            case 'POST':
            case 'PUT':
            case 'PATCH':
                return [
                    'position' => 'required|max:255',
                    'image' => 'required',
                    'level' => 'required',
                    'first_commission' => 'required',
                    'second_commission' => 'required',

                ];
                break;

        }
        return [];
    }

    /**
     * 验证信息
     *
     * @return array
     */
    public function ruleMessages(): array
    {
        return [
            'position.required' => '职位不能为空',
            'position.max' => '职位 不能超过225字符',
            'image.required' => '背景图不能为空',
            'level.required' => '等级不能为空',
            'first_commission.required' => '一级返佣比例不能为空',
            'second_commission.required' => ' 二级返佣比例不能为空',


        ];
    }
}
